package models

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type VideoListResponse struct {
	Response
	VideoList []Video `json:"video_list"`
}

// ResponseVideoListSuccess 视频列表成功
func ResponseVideoListSuccess(c *gin.Context, videoList []Video) {
	c.JSON(http.StatusOK, &VideoListResponse{
		Response:  Response{StatusCode: CodeSuccess, StatusMsg: ResCode.Msg(CodeSuccess)},
		VideoList: videoList,
	})
}

// ResponseVideoListError 视频列表错误
func ResponseVideoListError(c *gin.Context, code ResCode) {
	c.JSON(http.StatusOK, &VideoListResponse{
		Response:  Response{StatusCode: code, StatusMsg: code.Msg()},
		VideoList: []Video{},
	})
}

type Publisher struct {
	UserId     int64 `gorm:"primaryKey;autoIncrement:false"`
	VideoId    int64 `gorm:"primaryKey;autoIncrement:false"`
	CreateTime int64 `gorm:"autoCreateTime"`
}

/**
1) 用户1投稿视频2
	1.创建一个视频，videoId
	insert into Publisher(userId,videoId) values(1,2)
2) 用户1投稿的所有视频：
	select VideoId from Publisher where UserId =1 ORDER BY CreateTime DESC
3) 根据视频id查找发布者id
	select UserId from Publisher where VideoId=2
*/
